from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time

# 【Chrome浏览器123版本对应Chromedriver.exe下载，安装及环境变量配置】【https://blog.csdn.net/weixin_42329452/article/details/137053038】
# 【https://googlechromelabs.github.io/chrome-for-testing/】
# 注意【修改chrome.exe、chromedriver.exe路径】

# url=input('请输入https://网址')
# 选项
options = webdriver.ChromeOptions()
options.add_argument("--remote-debugging-port=9222")


# 路径
options.binary_location = r"G:\PC Package\Chrome\App\Chrome.exe"#[win8]
chrome_driver_path = r"G:\PC Package\Chrome\App\chromedriver.exe"
'''
# 路径win10
options.binary_location = r"D:\PC Package\Chrome 97.0.4692.71\App\Chrome.exe"win10
chrome_driver_path = r"D:\PC Package\Chrome 97.0.4692.71\App\chromedriver.exe"
# s=Service(r'D:\PC Package\Chrome\App\chromedriver.exe')
'''


# 服务
chrome_driver_path_obj = Service(chrome_driver_path)

driver = webdriver.Chrome(executable_path=chrome_driver_path,service=chrome_driver_path_obj,options=options)#成功 executable_path has been deprecated, please pass in a Service object

url='https://www.baidu.com'

driver.get(url)

# cmd管理员》netstat -ano |findstr 9222
# TCP  127.0.0.1:9222   0.0.0.0:0   LISTENING 4924
# TCP  127.0.0.1:9222   127.0.0.1:49676   ESTABLISHED 4924
# TCP  127.0.0.1:49676   127.0.0.1:9222   ESTABLISHED 2600
# 》tasklist |findstr 4924
# chrome.exe  4924 Console  1  89376K
# chromedriver.exe  2600 Console  1  10376K